﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class UserGroupBL
	{

		#region ***** Init Methods ***** 
		UserGroupDA objUserGroupDA;
		public UserGroupBL()
		{
			objUserGroupDA = new UserGroupDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get UserGroup by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>UserGroup</returns>
		public UserGroup GetByID(int id)
		{
			return objUserGroupDA.GetByID(id);
		}

		/// <summary>
		/// Get all of UserGroup
		/// </summary>
		/// <returns>List<<UserGroup>></returns>
		public List<UserGroup> GetList()
		{
			string cacheName = "lstUserGroup";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objUserGroupDA.GetList(), "UserGroup");
			}
			return (List<UserGroup>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of UserGroup
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsUserGroup";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objUserGroupDA.GetDataSet(), "UserGroup");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of UserGroup paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<UserGroup>></returns>
		public List<UserGroup> GetListPaged(int recperpage, int pageindex)
		{
			return objUserGroupDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of UserGroup paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objUserGroupDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new UserGroup within UserGroup database table
		/// </summary>
		/// <param name="obj_usergroup">UserGroup</param>
		/// <returns>key of table</returns>
		public int Add(UserGroup obj_usergroup)
		{
			ServerCache.Remove("UserGroup", true);
			return objUserGroupDA.Add(obj_usergroup);
		}

		/// <summary>
		/// updates the specified UserGroup
		/// </summary>
		/// <param name="obj_usergroup">UserGroup</param>
		/// <returns></returns>
		public void Update(UserGroup obj_usergroup)
		{
			ServerCache.Remove("UserGroup", true);
			objUserGroupDA.Update(obj_usergroup);
		}

		/// <summary>
		/// Delete the specified UserGroup
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("UserGroup", true);
			objUserGroupDA.Delete(id);
		}
		#endregion
	}
}
